import { getVillageList,checkZzCpAbility } from '@/api/index/index'
export default{
	data(){
		return{
			gridIndex:-1,
			isSelGridFlag:false,
			gridList:[],
			groupId:0,
			hasAbility:null,
			msg:''
		}
	},
	methods:{
		loadGridList(){
			getVillageList().then(res=>{
				//console.log(res)
				this.gridList = res.data.datas;
				if(this.gridList.length == 1){
					this.gridIndex = 0;
					this.isSelGridFlag = true;
					this.gridName = this.gridList[this.gridIndex].village;
					this.groupId = this.gridList[this.gridIndex].groupId;
					if(this.currPage == 'selAreaCp'){//选择测评区域时判断是否有权限测评
						this.checkZzCp();
					}
				}
			}).catch(err=>{
				console.log(err)
			})
		},
		checkZzCp(){
			let field = { orderId:this.orderId }
			checkZzCpAbility(field).then(res=>{
				console.log(res)
				this.hasAbility = true;
			}).catch(err=>{
				this.hasAbility = false;
				this.msg = err.data.message;
			})	
		},
		goSelGrid(e){
			this.gridIndex = e.detail.value;
			this.isSelGridFlag = true;
			this.gridName = this.gridList[this.gridIndex].village;
			this.groupId = this.gridList[this.gridIndex].groupId;
			if(this.currPage == 'selAreaCp'){
				this.checkZzCp();
			}
		},
	}
}